package com.maotouying.owlsmart.userPage;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;

import com.maotouying.owlsmart.InitActivity;
import com.maotouying.owlsmart.LoginPage.LoginActivity;
import com.maotouying.owlsmart.MainPage.FragmentManagerActivity;
import com.maotouying.owlsmart.R;
import com.maotouying.owlsmart.SmartUtil.Sqlite.DatabaseHelper;
import com.maotouying.owlsmart.SmartUtil.Sqlite.dbUtil;

public class SettingActivity extends AppCompatActivity implements View.OnClickListener {

    private LinearLayout ll_logout;
    private SQLiteDatabase db;
    private DatabaseHelper helper;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_setting);
        //初始化数据库
        initsqlite();
        initView();

    }


    private void initsqlite() {
        helper = new DatabaseHelper(this, "db_owlsmart", null, R.string.db_version);//dbName数据库名
        db = helper.getWritableDatabase();//获取到了 SQLiteDatabase 对象
    }



    private void initView(){

        ll_logout = (LinearLayout)findViewById(R.id.ll_logout);




        ll_logout.setOnClickListener(this);


    }


    @Override
    public void onClick(View v) {
        int id = v.getId();
        switch(id) {
            case R.id.ll_logout:
                //点击退出登录，清空用户表
                dbUtil dbu = new dbUtil();
                dbu.deleteTable(db,"presentTable");

                //去到登录页面
                Intent intent = new Intent(SettingActivity.this, LoginActivity.class);
                startActivity(intent);
                break;

        }

    }
}